﻿using UnityEngine;
using System.Collections;

public class ProgressTimeBar : MonoBehaviour {

	public Texture2D timeProgressBar;
	float timeProgress = 0;

	void OnGUI(){

		//GUI.DrawTexture (new Rect(Screen.s/2 - 100,7,timeProgressBar.width,timeProgressBar.height), timeProgressBar);
		if (Program.isClicked == true) {
			GUI.DrawTexture (new Rect (Screen.width/2 - 123,
			                           6, 
			                           timeProgressBar.width + 30 - timeProgress,
			                           timeProgressBar.height),
			              			   timeProgressBar);

		}

	}

	void Update(){
		if(timeProgress < (timeProgressBar.width + 30) && Program.isClicked == true && Program.isStop == false){
			timeProgress += Time.deltaTime * (timeProgressBar.width + 35) / 20;
		}
		if(timeProgress >= timeProgressBar.width + 30 && Program.isStop == false){
			Program.isStop = true;
		}

	}
}
